package com.sfx.concurrent.demo.线程基础;

import cn.hutool.core.util.StrUtil;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

class ExtractMainDomain {
    public static void main(String[] args) throws URISyntaxException {
        String url = "https://zhuanlan.zhihu1.com/p/43289968";

        List<String> details = Arrays.asList("nageoffer.com", "zhihu.com", "juejin.cn", "cnblogs.com");
        String domain = "";
        URI uri = new URI(url);
        String host = uri.getHost();
        if (StrUtil.isNotBlank(host)) {
            domain = host;
            if (domain.startsWith("www.")) {
                domain = host.substring(4);
            }
        }
        String finalDomain = domain;
        boolean b = details.stream().anyMatch(finalDomain::endsWith);
        System.out.println(b);

        System.out.println(domain);
    }
}